<?php


namespace app\api\controller\xiluedu;


use app\common\controller\Api;
use app\common\model\xiluedu\Ticket AS TicketModel;

class Ticket extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    /**
     * 获取开票信息
     */
    public function get_ticket(){
        $row = TicketModel::where('user_id',$this->auth->id)->find();

        $this->success('查询成功',$row);
    }

    /**
     * 添加信息
     */
    public function add_ticket(){
        $params = $this->request->post('');
        $params['user_id'] = $this->auth->id;
        $validate = new \app\common\validate\xiluedu\Ticket();
        if(!$validate->check($params)){
            $this->error($validate->getError());
        }
        $ticket = new TicketModel();
        $ret = $ticket->save($params);
        if($ret===false) {
            $this->error($ticket->getError());
        }
        $this->success('提交成功');
    }

}